package com.yangxk.kadmin.web.module.gen.controller;

import com.github.pagehelper.PageInfo;
import com.yangxk.kadmin.common.beans.Result;
import com.yangxk.kadmin.web.common.annotation.DemoModel;
import com.yangxk.kadmin.web.module.gen.form.GenLogQueryForm;
import com.yangxk.kadmin.web.module.gen.po.GenLog;
import com.yangxk.kadmin.web.module.gen.service.GenLogService;
import com.yangxk.kadmin.web.module.gen.vo.GenLogDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/genlog")
public class GenLogController {
    @Autowired
    private GenLogService genLogService;

    @RequestMapping("/list")
    public Result<PageInfo<GenLog>> findByPage(GenLogQueryForm queryForm) {
        PageInfo<GenLog> page = genLogService.findByPage(queryForm);
        return Result.ofSuccess(page);
    }

    @RequestMapping("/detail")
    public Result<GenLogDetail> detail(long genLogId) {
        GenLogDetail detail = genLogService.findDetail(genLogId);
        return Result.ofSuccess(detail);
    }

    @DemoModel
    @RequestMapping("/reset")
    public Result reset(long genLogId) {
        genLogService.repealGen(genLogId);
        return Result.ofSuccess();
    }
}
